<template>
	<view>
		<button @click="onSetTimeCall()">单词计时器setTimeout</button>
		<button @click="onSetTimeCallxy(userName,password)">带参数setTimeout</button>
		<button @click="onSetTimeClear()"type="warn">取消定时器</button>
		<button @click="onInteral()"type="primary">周期打印</button>
		<button @click="on()"type="warn">取消定时器</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName:'lh',
				password:'666',
				timeoutID:null,
				count:0,
			}
		},
		methods: {
			onSetTimeCall(){
				console.log("onSetTimeCall-->");
				// settimeout(callback,ms,ayn[])
				// 箭头函数（匿名函数）（）+>{}
				setTimeout(()=>{
						// 延时之后要执行的代码
						console.log("我延时两秒才会打印");
				},2000)
			},
			onSetTimeCallxy(name,pwd){
				console.log("onSetTimeCallxy--> name:"+name+",pwd:"+pwd);
				setTimeout((x,y)=>{
					console.log("我可以传参数了>x:"+x+",y:"+y);
				},2000,name,pwd)
			},
			onSetTimeClear(){
				console.log("onSetTimeClear---->定时器被我取消了:"+this.timeoutID);
				clearTimeout(this.timeoutID);
			},
			onInteral(){
		  thsetInterval(()=>{
					this.count++;
					console.log("周期打印 count:",this.count);
				},1000)
			},
			onClearInter(){
				console.log("onClearInter:",)
			}
		}
	}
</script>

<style>
button{
	margin: 30rcap;
}
</style>
